﻿using System.IO;
using System.Text;

namespace ReadTxt
{
    class Program
    {
        static void Main(string[] args)
        {
            ReadFile();
        }
        public static void ReadFile()
        {
            var file = Directory.GetCurrentDirectory()+"\\TextFile.txt";
            var write = File.OpenWrite(file);
            Encoding encoder = Encoding.UTF8;
            byte[] bytes = encoder.GetBytes("这是新添加的内容+"+DateTime.Now+" \n\r");
            write.Position = write.Length;
            write.Write(bytes, 0, bytes.Length);
            write.Dispose();
            ReadFileNew(file);
        }
        public static string ReadFileNew(string? file)
        {
            var stream = new StreamReader(file);
            var data = stream.ReadToEnd();
            Console.WriteLine("第二个方法读取："+data);
            return data;
        }
    }
}